package online.shenme.day14_self.dao;

import online.shenme.day14_self.domin.Manager;

import java.io.*;
import java.util.HashMap;

public class ManagerDAO implements DAO<String, Manager> {
    @java.io.Serial
    private static final HashMap<String, Manager> mgMap = new HashMap<>();

    public ManagerDAO() {
        try {
            BufferedReader br=new BufferedReader(new FileReader("javaadvance/src/online/shenme/day14_self/domin/manager.txt"));
            String s;
            while ((s=br.readLine())!=null){
                String[] split = s.split(",");
                mgMap.put(split[0],new Manager(split[0],split[1],split[2].toCharArray()[0],Long.valueOf(split[3])));
            }
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public HashMap<String, Manager> findAll() {

        return mgMap;
    }

    @Override
    public boolean delete(String id) {
        return false;
    }

    @Override
    public boolean reSet(String id, Manager manager) {
        return false;
    }

    @Override
    public boolean add(String s, Manager manager) {
        return false;
    }

    public Manager getById(String id) {
        return mgMap.get(id);
    }
}
